import time

from selenium.webdriver.common.by import By

from base.page_base import BasePage


class BorrowAudit(BasePage):


     #元素定位
     click_mana_01=(By.XPATH,'/html/body/div[1]/div[2]/ul/li[2]/a')
     click_first_02=(By.XPATH,'//*[@id="sidebar"]/ul/li[2]/a/span')
     click_await_03=(By.XPATH,'//*[@id="sidebar"]/ul/li[2]/ul/li[1]/a')
     new_frome=(By.ID,'iframe_box')
     input_name_04=(By.NAME,'userName')
     click_search_05=(By.XPATH,'/html/body/div[2]/div[1]/div/ul/li[8]/input')
     click_headline_06=(By.XPATH,'/html/body/div[2]/div[3]/table/tbody/tr[1]/td[1]/span')
     click_audit_button_07=(By.XPATH,'/html/body/div[2]/div[2]/ul/li[2]/a/span')
     new_frome2_08=(By.XPATH,'/html/body/div[5]/div[1]/iframe')
     click_pass_button_09=(By.XPATH,'/html/body/div[2]/form/table/tbody/tr[3]/td[2]/div/label[1]/input')
     input_marker_type_10=(By.NAME,'marker_type')
     input_remark_11=(By.XPATH,'/html/body/div[2]/form/table/tbody/tr[5]/td[2]/div/textarea')
     input_code_12=(By.XPATH,'/html/body/div[2]/form/table/tbody/tr[6]/td[2]/div/ul/li[1]/input')
     click_submit_13=(By.XPATH,'/html/body/div[2]/form/table/tbody/tr[7]/td[2]/input[1]')
     click_first_man_14=(By.XPATH,'//*[@id="sidebar"]/ul/li[3]/a/span')
     click_being_borr_15=(By.XPATH,'//*[@id="sidebar"]/ul/li[3]/ul/li[1]/a')
     click_message_16=(By.XPATH,'/html/body/div[2]/div[3]/table/tbody/tr[1]/td[9]/span')

     def click_stration(self):
         """前三步
            点击借款管理
            点击初审管理
            点击初审标
         """
         self.base_click(self.click_mana_01)
         self.base_click(self.click_first_02)
         self.base_click(self.click_await_03)

     def search_message(self,name):
         """搜索信息
         输入手机号
         点击搜索
         选中审核内容
         点击审核按钮
         """
         self.base_switch_frame(self.new_frome)
         self.base_input(self.input_name_04,name)
         self.base_click(self.click_search_05)
         time.sleep(1)
         self.base_click(self.click_headline_06)
         self.base_click(self.click_audit_button_07)

     def audit_course(self,marker,remark,code):
         """审核操作
            点击通过按钮
            输入标签
            输入备注
            输入验证码
            点击同意按钮
         """
         self.base_switch_frame(self.new_frome2_08)
         time.sleep(1)
         self.base_click_special(self.click_pass_button_09)
         self.base_input(self.input_marker_type_10,marker)
         self.base_input(self.input_remark_11,remark)
         self.base_input(self.input_code_12,code)
         self.base_click(self.click_submit_13)


     def borrow_audit_bus(self,name,marker='测试',remark='测试需要',code='8888'):
         """借款审核业务全流程
         """
         self.click_stration()
         self.search_message('13810012011')
         self.audit_course(marker,remark,code)
     def gain_result(self,name):
         """断言信息
         切换到默认frame
         点击借款中管理
         点击正在借款
         切换到新的frame
         输入手机号
         点击搜索
         获取文本

         """
         self.base_default_frame()

         self.base_click(self.click_first_man_14)

         self.base_click(self.click_being_borr_15)

         self.base_switch_frame(self.new_frome)
         self.base_input(self.input_name_04,name)
         self.base_click(self.click_search_05)
     def get_result_text(self):
         time.sleep(1)
         return self.fd_element(self.click_message_16).text




